$.bsgrid.forcePushPropertyInObject($.fn.bsgrid.defaults.extend.renderPerRowMethods, 'extend_render_per_row', function(record, rowIndex, trObj, options){
    						if(record!=undefined && record!=''){
      							trObj.attr('id',record.id);
    						}
  					});
$(function () {
	//获取参数
	var menuId = '';
	var parArr = [];
	var parMap = {};
	var src = tl_config.his_url;
	var i = src.indexOf('?')+1;  //开始位置
	var params = src.substring(i);  
	parArr = params.split('&'); //获取所有参数数组
	for(var j in parArr){
		var key = parArr[j].substring(0,parArr[j].indexOf('='));//截取参数名
		parMap[key]= parArr[j].substring(parArr[j].indexOf('=')+1);//获取参数值
	}
    menuId = parMap['menuId'];
    	$("#menuId").val(menuId);
    	queryList(menuId);
});
function queryList(menuId){
	var token=localStorage.getItem("token");
	//var menuId=$("#menuId").val();
	    gridObj = $.fn.bsgrid.init('g_tabYeh', {

			ajaxType: 'get',
			url: server_url+'rest/operationList.do?ran='+Math.random()+'&token='+token,
			otherParames:{menuId:menuId},
			autoLoad: true,
			pageSizeSelect: true,
			stripeRows: true,
			pageSize: 10,
			displayBlankRows: false,
			isProcessLockScreen:true,
			rowSelectedColor:false
});
} 
function operate(record, rowIndex, colIndex, options) {
	return '<a href="javascript:EditOperation(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">编辑</a>';
}
//到编辑页面
function EditOperation(id){

	//location.href='http://localhost:8081/LianniuManager/operationEdit.do?id='+id;
	var url = 'operationEdit.do?id='+id;
	tl_config.loadToWorkArea(url);
}  
//到新增页面
function addOper(){
	var menuId = $("#menuId").val();
	var url ='operationAdd.do?menuId='+menuId;
	tl_config.loadToWorkArea(url);
}
//获取checkbox选中
var chk= '';
function getCheckedIds() {
	var menuId = $("#menuId").val();
    var idArr = gridObj.getCheckedValues('id');
    if(idArr.length==0){
//    	alert("请选择要删除的操作");
    	easyDialog.open({
		  container : {
			    header : '提示框',
			    content : '请选择要操作的记录！'
		  },
    	autoClose : 2000//两秒自动关闭
    	});
    	return false;
    }
    for (var i = 0; i < idArr.length; i++) {
		chk = chk+'-'+idArr[i];
	}
    chk = chk.substring(1,chk.length);
  
    easyDialog.open({
		container:{
			header:'提示框',
			content:'您确定要删除吗?',
			yesFn:delOper,
			noFn:true
		} 
	});
    	
        	   
	}
function delOper(){
	var menuId = $("#menuId").val();
	var token=localStorage.getItem("token");
	  $.ajax({
		  url:server_url+'rest/delOperation.do?ran='+Math.random()+'&token='+token,
		  type:'get',
		  cache:false ,
		  data:{chk:chk},
		  success:function(data){
			/*easyDialog.open({
				container:{
					header:'返回信息',
					content:data.retMsg
				},
				autoClose : 2000//两秒自动关闭
			});*/
			  var url ='operationList.do?menuId='+menuId;
			  tl_config.loadToWorkArea(url);
    	          		  }
    	     });
	
}
//返回上一级
function retLast(){
	var url ='menuList.do';
	tl_config.loadToWorkArea(url);
}
  